import Vue from 'vue'
import Router from 'vue-router'

const asyncComponent = (name) => {
    return resolve => require([`@/pages/${name}.vue`], resolve)
}
const Index = asyncComponent('Index')
const Login = asyncComponent('Login')
const Registered = asyncComponent('Registered')
const News = asyncComponent('News')
Vue.use(Router)

export default new Router({
    mode: 'history',
    routes: [
	    {
	        path: '/',
	        name: 'index',
	        component: Index,
	        meta: {
		    	title: '首页入口',                                               
		    	requireAuth: false  // 添加该字段，表示进入这个路由是需要登录的
		   	}
	    }, 
	    {
	        path: '/login',
	        name: 'login',
	        component: Login,
	        meta: {
	        	title:'登录',
	            requireAuth: false,  // 添加该字段，表示进入这个路由是需要登录的
	        }
	    },
	    {
	    	path:'/registered',
	    	name:'registered',
	    	component: Registered,
	        meta: {
	        	title: '注册',
	            requireAuth: false,  // 添加该字段，表示进入这个路由是需要登录的
	        }
	    },
	    {
	    	path:'/news',
	    	name:'news',
	    	component: News,
	        meta: {
	        	title: '消息中心',
	            requireAuth: false,  // 添加该字段，表示进入这个路由是需要登录的
	        }
	    }

    ]
})
